Skip to content

Conversation

@ArgoZhang
Copy link
Member

@ArgoZhang ArgoZhang commented Oct 28, 2025

Link issues

fixes #7018

Summary By Copilot

Regression?

  • Yes
  • No

Risk

  • High
  • Medium
  • Low

Verification

  • Manual (required)
  • Automated

Packaging changes reviewed?

  • Yes
  • No
  • N/A

☑️ Self Check before Merge

⚠️ Please check all items below before review. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • Merge the latest code from the main branch

Summary by Sourcery

Fix auto-scrolling of the last selected row in ClickSelect mode and refactor scroll logic

Bug Fixes:

  • Enable AutoScrollLastSelectedRowToView support in ClickSelect mode by selecting rows with the 'active' class

Enhancements:

  • Extract getSelectedRow helper to simplify selection logic in Table scroll function

Copilot AI review requested due to automatic review settings October 28, 2025 09:33
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Oct 28, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Refactor auto-scroll behavior by introducing a helper that identifies the last selected row via its active state, enabling support for ClickSelect mode.

Class diagram for updated Table auto-scroll logic

classDiagram
class Table {
}
class getSelectedRow_element_ {
  +element: HTMLElement
  +returns: HTMLElement | undefined
}
Table --> getSelectedRow_element_ : uses
Loading

Flow diagram for auto-scroll to last selected row in ClickSelect mode

flowchart TD
    A["User selects a row (ClickSelect mode)"] --> B["Row gets 'active' class"]
    B --> C["scroll() function called"]
    C --> D["getSelectedRow(element) finds last 'tr.active'"]
    D --> E["Scrolls row into view"]
Loading

File-Level Changes

Change Details Files
Refactor row selection logic in scroll function to support ClickSelect mode
  • Replace direct checkbox-based querySelectorAll('.form-check.is-checked') with a call to getSelectedRow
  • Add getSelectedRow helper to query for 'tr.active' rows and return the last one
src/BootstrapBlazor/Components/Table/Table.razor.js

Assessment against linked issues

Issue Objective Addressed Explanation
#7018 Fix the bug where setting AutoScrollLastSelectedRowToView=true does not scroll the newly selected row into the visible area when SelectedRow changes.
#7018 Update the Table.razor.js scroll logic to correctly identify the selected row by its 'active' class, not just '.form-check.is-checked'.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@bb-auto bb-auto bot added the bug Something isn't working label Oct 28, 2025
@bb-auto bb-auto bot added this to the 9.11.0 milestone Oct 28, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes the AutoScrollLastSelectedRowToView feature in the Table component to support ClickSelect mode by changing the row selection detection logic from checkbox-based to row-based selection.

Key Changes:

  • Updated the scroll function to detect selected rows using tr.active class instead of checkbox states
  • Version bumps for both beta and release candidate versions

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/BootstrapBlazor/Components/Table/Table.razor.js Refactored row selection detection to support ClickSelect mode by introducing getSelectedRow helper function
src/BootstrapBlazor/BootstrapBlazor.csproj Version bumps from 9.11.5-beta08 to beta09 and 10.0.0-rc.2.1.7 to rc.2.1.8

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

sourcery-ai[bot]
sourcery-ai bot previously approved these changes Oct 28, 2025
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - I've reviewed your changes - here's some feedback:

  • Consider falling back to the original .form-check.is-checked selector if no tr.active is found to maintain compatibility with non-ClickSelect modes.
  • Since getSelectedRow is only used once, you might inline it into scroll to simplify the code and avoid an extra function.
  • Using pop() will always pick the last active row; double-check whether selecting the first or last active row aligns with expected multi-select behavior.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider falling back to the original `.form-check.is-checked` selector if no `tr.active` is found to maintain compatibility with non-ClickSelect modes.
- Since `getSelectedRow` is only used once, you might inline it into `scroll` to simplify the code and avoid an extra function.
- Using `pop()` will always pick the last active row; double-check whether selecting the first or last active row aligns with expected multi-select behavior.

## Individual Comments

### Comment 1
<location> `src/BootstrapBlazor/Components/Table/Table.razor.js:232-235` </location>
<code_context>
     }
 }

+const getSelectedRow = element => {
+    const rows = [...element.querySelectorAll('tr.active')];
+    return rows.pop()
+}
+
</code_context>

<issue_to_address>
**suggestion:** Using 'pop()' on the array of active rows will select the last active row, which may not always be the intended behavior.

If only one row should be active, use 'find' or access the first element for clarity. If multiple can be active, specify which row should be selected.

```suggestion
const getSelectedRow = element => {
    const rows = [...element.querySelectorAll('tr.active')];
    return rows.length > 0 ? rows[0] : null;
}
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@ArgoZhang ArgoZhang merged commit cd3f29b into main Oct 28, 2025
5 checks passed
@ArgoZhang ArgoZhang deleted the fix-table branch October 28, 2025 09:35
@codecov
Copy link

codecov bot commented Oct 28, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (c29d23a) to head (4159ee8).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #7019   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          743       743           
  Lines        32451     32451           
  Branches      4495      4495           
=========================================
  Hits         32451     32451           
Flag Coverage Δ
BB 100.00% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(Table): Table的AutoScrollLastSelectedRowToView不生效

3 participants